<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>arthur.js</title>
        <script type="text/javascript" src="../dist/avalon.js"></script>

    </head>
    <body>
        <div id="aaa"></div>

          <script>
        function heredoc(fn) {
    return fn.toString().replace(/^[^\/]+\/\*!?\s?/, '').
            replace(/\*\/[^\/]+$/, '').trim().replace(/>\s*</g, '><')
}
var textProp = 'textContent' in document ? 'textContent': 'innerText'
function fireClick(el) {
    if (el.click) {
        el.click()
    }else {
//https://developer.mozilla.org/samples/domref/dispatchEvent.html
        var evt = document.createEvent('MouseEvents')
        evt.initMouseEvent('click', true, true, window,
                0, 0, 0, 0, 0, false, false, false, false, 0, null);
        !el.dispatchEvent(evt);
    }
}

function expect(a){
    return {
        toBe:function(b){
            console.log(a, b, a === b)
        }
    }
}
        var div = document.getElementById('aaa')
          div.innerHTML = heredoc(function () {
            /*
             <input type='radio' ms-controller='attr1' ms-attr='{checked:@a}' >
             */
        })
        vm = avalon.define({
            $id: 'attr1',
            a: true
        })
        avalon.scan(div)
        var el = div.children[0]
     
            expect(el.checked).toBe(true)
            console.log('  第一次求值 ',el.nodeName)
            vm.a = false
            setTimeout(function () {
                expect(el.checked).toBe(false)
  console.log('  第2次求值 ')
                fireClick(div.children[0])
                setTimeout(function () {
                    expect(el.checked + '1').toBe('true1')
                   console.log('  第3次求值 ')
                }, 1000)

            }, 100)
     
    
    </script>
    </body>
</html>